<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('新增模块')"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-module-add">
        <div class="form-group">
            <label class="col-sm-2 control-label">表前缀：</label>
            <div class="col-sm-3">
                <input id="datasourceId" name="datasourceId" type="hidden">
                <input id="tablePrefix" name="tablePrefix" class="form-control" value="sys_" type="text">
            </div>
            <label class="col-sm-2 control-label">是否移除：</label>
            <div class="col-sm-3">
                <label class="radio-box"> <input type="radio" name="autoRemovePre" value="true"/> 是 </label>
                <label class="radio-box"> <input type="radio" name="autoRemovePre" value="false" checked/> 否 </label>
            </div>

        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">作者：</label>
            <div class="col-sm-3">
                <input id="author" name="author" class="form-control" value="devtools" type="text">
            </div>
            <label class="col-sm-2 control-label">模块：</label>
            <div class="col-sm-3">
                <input id="moduleName" name="moduleName" class="form-control" value="tool" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">包路径：</label>
            <div class="col-sm-8">
                <input id="packageName" name="packageName" class="form-control" value="com.devtools.project"
                       type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">表名：</label>
            <div class="col-sm-8">
                <textarea id="tables" name="tables" class="form-control"></textarea>
            </div>
        </div>
    </form>
</div>
<div th:include="include::footer"></div>
<script type="text/javascript">
    var datasourceId = GetQueryString("datasourceId");
    var tables = GetQueryString("tables");
    $("#tables").val(tables);
    $("#datasourceId").val(datasourceId);
    var prefix = ctx + "tool/datasource"

    function submitHandler() {
        if ($.validate.form()) {
            $.modal.confirm("确定生成代码吗？", function() {
                $.modal.loading("正在生成代码，请稍后...");
                $.post(prefix + "/batchGenCode",$('#form-module-add').serialize(), function(result) {
                    if (result.code == web_status.SUCCESS) {
                        window.location.href = ctx + "common/download?fileName=" + encodeURI(result.msg) + "&delete=" + true;
                    } else if (result.code == web_status.WARNING) {
                        $.modal.alertWarning(result.msg)
                    } else {
                        $.modal.alertError(result.msg);
                    }
                    $.modal.closeLoading();
                });
            });
        }
    }
</script>
</body>
</html>
